package cn.omisheep.au;


import cn.omisheep.au.core.*;
import cn.omisheep.au.core.filter.AuDecryptRequestBodyAdvice;
import cn.omisheep.au.core.filter.AuFilter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;

/**
 * @author zhou xin chen  😊
 * 联系方式 qq:1269670415  email:xinchenzhou666@gmail.com
 */
@Configuration
@ConditionalOnBean(AuInit.class)
public class AuAutoConfiguration {


    @Bean
    @ConditionalOnMissingBean
    public AuConfig auConfig() {
        return new AuConfig();
    }


    @Bean
    @ConditionalOnMissingBean
    public AuFactory auFactory() {
        return new AuFactory();
    }


    @Bean
    @ConditionalOnMissingBean
    public AuFilter auFilter() {
        return new AuFilter();
    }


    @Bean
    @ConditionalOnMissingBean
    @Lazy
    public AuHandlerRegister auHandlerRegister() {
        return new AuHandlerRegister();
    }


    @Bean
    @ConditionalOnMissingBean
    public AuDecryptRequestBodyAdvice auDecryptRequestBodyAdvice() {
        return new AuDecryptRequestBodyAdvice();
    }


    @Bean
    @ConditionalOnMissingBean
    public AuKey auKey() {
        return new AuKey();
    }


    @Bean
    @ConditionalOnMissingBean
    public AuValidate auValidate(AuConfig auConfig, AuCore auCore) {
        return new AuValidate(auConfig, auCore);
    }

    @Bean
    @ConditionalOnMissingBean
    public AuCore auCore(AuConfig auConfig) {
        return new AuCore(auConfig);
    }


    @Bean
    @ConditionalOnMissingBean
    public JwtHelper jwtHelper(AuConfig auConfig) {
        return new JwtHelper(auConfig);
    }


    @Bean
    @ConditionalOnMissingBean
    public AuHelper auHelper() {
        return new AuHelper();
    }

}
